
idf_component_register(SRCS 
	lapi.c 
	lcode.c
	lctype.c
	ldebug.c
	ldo.c
	ldump.c
	lfunc.c
	lgc.c
	llex.c
	lmem.c
	lobject.c
	lopcodes.c
	lparser.c
	lstate.c
	lstring.c
	ltable.c
	ltm.c
	lundump.c
	lvm.c
	lzio.c

    lauxlib.c
	lauxlib.c
	lbaselib.c
	lcorolib.c
	ldblib.c
	liolib.c
	lmathlib.c
	loadlib.c
	loslib.c
	lstrlib.c
	ltablib.c
	lutf8lib.c
	linit.c
	lbaselib.c
	lcorolib.c
	ldblib.c
	liolib.c
	lmathlib.c
	loadlib.c
	loslib.c
	lstrlib.c
	ltablib.c
	lutf8lib.c
	linit.c
    INCLUDE_DIRS ".")

target_compile_definitions(${COMPONENT_LIB} PUBLIC USE_LUA)

# 修改luaconf.h第125行 `#define LUA_32BITS	0` 为 `#define LUA_32BITS	1`

if (PREBUILT_DIRECTORY)
	file(REMOVE_RECURSE ${PREBUILT_DIRECTORY}/include/Lua)
	file(MAKE_DIRECTORY ${PREBUILT_DIRECTORY}/include/Lua)
	file(GLOB BUILD_HEADER_FILES "${CMAKE_CURRENT_SOURCE_DIR}/*.h")
	file(COPY ${BUILD_HEADER_FILES} DESTINATION ${PREBUILT_DIRECTORY}/include/Lua)

	add_custom_command(TARGET ${COMPONENT_LIB} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${COMPONENT_LIB}> ${PREBUILT_DIRECTORY}/lib COMMENT "Copying built archive file to prebuilt directory...")
endif()